const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')

function resolve(dir) {
    return path.join(__dirname, dir);
}

const AppName = "APP名称"
module.exports = {
    publicPath: './',

    devServer: {
        // can be overwritten by process.env.HOST
        host: '0.0.0.0',
        port: 8080,

        // proxy: {
        //   '/api': {
        //     target: 'http://localhost:5000', //API服务器的地址
        //     ws: true,  //代理websockets
        //     changeOrigin: true, // 虚拟的站点需要更管origin
        //     pathRewrite: {   //重写路径 比如'/api/aaa/ccc'重写为'/aaa/ccc'
        //       '^/api': ''
        //     }
        //   }
        // },
    },

    configureWebpack: config => {
        config.plugins.forEach((val) => {
            if (val instanceof HtmlWebpackPlugin) {
                val.options.title = AppName
            }
        })
    },

    pluginOptions: {
        electronBuilder: {
            nodeIntegration: true,
            builderOptions: {
                win: {
                    icon: './public/app.ico'
                },
                mac: {
                    icon: './public/app.png'
                },
                productName: AppName
            }
        }
    },

    chainWebpack: config => {
        //目录简写
        config.resolve.alias
            .set('@', resolve('src'))
            .set('src', resolve('src'))
            .set('utils', resolve('src/utils'))
            // .set('components', resolve('src/components'));
    },

    lintOnSave: false
};